home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
AMIGA
/
AMICUS
/
AMICUS04.ADF
/
image.ed
/
changecolor.c
< prev
next >
Wrap
C/C++ Source or Header
|
1985-10-26
|
10KB
|
277 lines
/************* changecolor3.c ************/
#include "intuall.h"
#include "imageedit.h"
#define SLIDERGADGETS 0x64 /* later move into imageedit.h */
/* this file contains the information for the requester that allows you
* to change the colors that are being used for the image editor. */
/* there are 3 porportional gadgets, one for the red, one for green and
* one for blue
*
* Each points to the same image data for rendering the gadget
*/
#define CGW 18
#define CGH 12
extern SHORT palette[];
extern SHORT depth;
struct Gadget ncp[33];
struct Image cri[33];
struct Requester newcolorrequest;
SHORT wc[] = { 0, 0, /* this describes a box to draw */
80, 0,
80, 10,
0, 10,
0, 1,
79, 1,
79, 9,
1, 9,
1, 1 }; /* the line is double-width */
struct Border whichcolor = {
210, 2, 0, 1, JAM1, 9, &wc[0], NULL };
/* initial offset position from 0,0 within requester x,y */
/* then drawing pens for rendering, and draw mode */
/* how many pairs of points defined, and where */
/* and is there a nextborder? */
extern struct TextAttr TestFont;
struct IntuiText ncrt[] = { /* ncrt stands for new color requester text */
/* requester IntuiText for this color requester */
{ 0,1,JAM1, 5, 1, &TestFont, (UBYTE *)"Select A Color:",
&ncrt[1], }
{ 0,1,JAM1, 5, 15, &TestFont, (UBYTE *)"R:",
&ncrt[2], }
{ 0,1,JAM1, 5, 28, &TestFont, (UBYTE *)"G:",
&ncrt[3], }
{ 0,1,JAM1, 5, 41, &TestFont, (UBYTE *)"B:",
&ncrt[4], }
{ 0,1,JAM1, 5, 65, &TestFont, (UBYTE *)"Move Sliders To Change It",
&ncrt[5], }
{ 0,1,JAM1, 5, 78, &TestFont, (UBYTE *)"Click OK To Exit",
&ncrt[6], }
{ 0,1,JAM1, 5, 53, &TestFont, NULL,
NULL, }
/* ncrt[6].IntuiText is used to identify the requester */
/* gadget IntuiText for this color requester */
{ 1,0,JAM2, 1, 0, &TestFont, (UBYTE *)"OK",
NULL }
};
UWORD horizslider[] = {
0xc000, /* first plane of image */
0xf000,
0xfc00,
0xff00,
0xfc00,
0xf000,
0xc000,
0x0000, /* second plane of image */
0x3000,
0x3000,
0x3c00,
0x3000,
0x3000,
0x0000 }; /* forms a right-facing arrow pointer */
struct Image sliderimage1[] = {
{0,0,8,7,1,&horizslider[0],0x1,0,}
{0,0,8,7,1,&horizslider[0],0x1,0,}
{0,0,8,7,1,&horizslider[0],0x1,0 } };
struct Image sliderimage2[] = {
{0,0,8,7,1,&horizslider[0],0x2,0,}
{0,0,8,7,1,&horizslider[0],0x2,0,}
{0,0,8,7,1,&horizslider[0],0x2,0 } };
struct PropInfo myslider[3] = { /* one for red,green,blue */
{FREEHORIZ, /* let it move freely in horizontal direction */
0,0, /* initial values of horizontal, vert. pot */
0x3fff, /* HorizBody ... not using autoknob so this
* may not be necessary to set to other than 0 */
0, /* VertBody */
0,0,0,0,0,0,} /* intuition's variables */
{FREEHORIZ,
0,0,
0x3fff,
0,
0,0,0,0,0,0,}
{FREEHORIZ,
0,0,
0x0, /* was 3fff, how far to move it when hit boxend */
0,
0,0,0,0,0,0} };
/* left edge, top edge, width, height, depth, predrawn image, ppick, pponoff */
/*
struct Image sliderimage1 = {
0,0,
8,7,1,
&horizslider[0],
0x2,
0 };
struct Image sliderimage2 = {
0,0,
8,7,2,
&horizslider[0],
0x2,
0 };
*/
struct Gadget colorgadget[3] = { /* here is the gadgetset for changing
* red, green and blue components of
* a currently selected color blot.
* Links together the other predefined
* information.
*/
{ &colorgadget[1], /* next gadget in this list */
20,13, /* left edge, top edge of hitbox */
170,11, /* width and height of hitbox */
GADGIMAGE | GADGHIMAGE,/* flags */
RELVERIFY |GADGIMMEDIATE, /* activation flags */
PROPGADGET | REQGADGET, /* this is a proportional gadget */
&sliderimage1[0], /* render normally with this image */
&sliderimage2[0], /* render highlighted with this one */
NULL, /* no text for this prop gadget */
0x06, /* mutual exclude */
&myslider[0], /* special info = define of prop */
SLIDERGADGETS+0, /* this gadget's identifier for me */
NULL, } /* no user data on this one */
{ &colorgadget[2],
20,26,
170,11,
GADGIMAGE | GADGHIMAGE,/* flags */
RELVERIFY | GADGIMMEDIATE,
PROPGADGET | REQGADGET,
&sliderimage1[1],
&sliderimage2[1],
NULL,
0x05,
&myslider[1],
SLIDERGADGETS+1,
NULL, }
{ &ncp[0],
20,39,
170,11,
GADGIMAGE | GADGHIMAGE,/* flags */
RELVERIFY | GADGIMMEDIATE,
PROPGADGET | REQGADGET,
&sliderimage1[2],
&sliderimage2[2],
NULL,
0x03,
&myslider[2],
SLIDERGADGETS+2,
NULL } };
/* the OK gadget lets people decide accept the colors they have */
/* chosen. Should also install a default colors gadget! */
struct Gadget ColorOKGadget = {
&colorgadget[0] /* address of next gadget */
180,78,20,9, /* left,top,width,height of hitbox */
GADGHCOMP, /* flags */
RELVERIFY | GADGIMMEDIATE | ENDGADGET,
/* tell me only when he releases the
* mouse button and if over the
* gadget at that time */
REQGADGET | BOOLGADGET, /* is a requestor, string */
NULL, /* BORDER descriptor */
NULL, /* SELECT descriptor */
&ncrt[7], /* OK */
0, /* mutual exclusion (could use) */
NULL, /* special info */
255, /* gadget identifier, user */
NULL }; /* user data pointer */
InitColorRequest()
{
InitRequester(&newcolorrequest);
newcolorrequest.LeftEdge = 20;
newcolorrequest.TopEdge = 20;
newcolorrequest.Width = 320;
newcolorrequest.Height = 90;
newcolorrequest.ReqGadget = &ColorOKGadget;
newcolorrequest.ReqText = &ncrt[0];
newcolorrequest.BackFill = 1;
newcolorrequest.ReqBorder = &whichcolor;
return(0);
}
InitNewColorText()
{ InitPaletteGadgets(depth);
return(0); }
InitPaletteGadgets(depth)
SHORT depth;
{
SHORT n;
for(n=0; n<(palette[depth-1]+1); n++)
{
ncp[n].NextGadget = &ncp[n+1];
ncp[n].LeftEdge = 210 + (CGW+2) * (n % 4);
ncp[n].TopEdge = 14 + (CGH+2) * (n/4);
ncp[n].Width = CGW;
ncp[n].Height = CGH;
ncp[n].Flags = GADGIMAGE | GADGHBOX;
ncp[n].Activation = RELVERIFY | GADGIMMEDIATE;
ncp[n].GadgetType = BOOLGADGET | REQGADGET;
ncp[n].GadgetRender = &cri[n];
ncp[n].SelectRender = NULL;
ncp[n].GadgetText = NULL;
ncp[n].MutualExclude = 0;
ncp[n].SpecialInfo = NULL;
ncp[n].GadgetID = COLORGADGETS + n;
ncp[n].UserData = NULL;
cri[n].LeftEdge = 1;
cri[n].TopEdge = 1;
cri[n].Width = CGW-2;
cri[n].Height = CGH-2;
cri[n].Depth = depth;
cri[n].ImageData = NULL;
cri[n].PlanePick = 0;
cri[n].PlaneOnOff = n;
}
/* this gadget will be used to represent which color was selected,
* rather than fooling around with the various toggle-select flags
* for everybody and so on, simply change the gadget render for this
* last gadget on selecting anybody else in the color palette, the
* start a RefreshGadget with this last object in the chain.
*/
ncp[palette[depth-1]].LeftEdge = 211;
ncp[palette[depth-1]].TopEdge = 3;
ncp[palette[depth-1]].Width = 78;
ncp[palette[depth-1]].Height = 8;
cri[palette[depth-1]].Width = 76;
cri[palette[depth-1]].Height = 8;
ncp[palette[depth-1]].NextGadget = NULL;
return(0);
}